<template>
	<view class="mine-page page">
		<CustomNav title="我的报灾记录" :isBack="true"></CustomNav>
		<view class="info-block">
			<template v-if="list.length>0">
				<view class="info-list" v-for="item in list" :key="item.id"
					@click="navigate('/page_pack/user/record_detail?id='+item.id)">
					<view class="title">{{item.typeText}}</view>
					<view class="time-item">
						<view class="iconfont icon-a-217shijian"></view>
						<view class="time">{{item.createTime}}</view>
					</view>
				</view>
			</template>
			<view v-if="more==false&&list.length==0" class="empty">暂无数据</view>
			<view v-else-if="more==false&&list.length>0" class="empty">没有更多了</view>
		</view>
	</view>
</template>

<script>
	import {
		isMore
	} from '@/util/util'
	import {
		getUserDisasterList
	} from '@/api/user.js'
	export default {
		data() {
			return {
				conf: {
					page: 1,
					limit: 20
				},
				more: true,
				list: []
			}
		},
		methods: {
			handleRefresh() {
				this.conf.page = 1;
				this.more = true
				this.getList('refresh');
			},
			getList(type = '') {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getUserDisasterList(this.conf).then(res => {
					this.list = type == 'refresh' ? res.list : [...this.list, ...res.list];
					this.more = isMore(this.conf.page, this.conf.limit, res.count)
				}).finally(() => {
					uni.stopPullDownRefresh();
				})
			},
		},
		onPullDownRefresh() {
			this.handleRefresh();
		},
		onReachBottom() {
			if (this.more) {
				this.conf.page++;
				this.getList();
			}
		},
		onLoad() {
			this.getList('refresh');
		}
	}
</script>

<style lang="scss" scoped>
	.mine-page {
		overflow: hidden;

		.info-block {
			margin-top: 23%;
			padding: 30rpx;
			background-color: #F7F6F9;
			min-height: 80vh;

			.info-list {
				background-color: #fff;
				border-radius: 20rpx;
				padding: 30rpx;
				margin-bottom: 20rpx;

				.title {
					width: 100%;
					font-size: 36rpx;
					font-weight: bold;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				.time-item {
					display: flex;
					align-items: center;
					font-size: 30rpx;
					color: #767676;
					margin-top: 30rpx;

					.iconfont {
						margin-right: 10rpx;
						font-size: 32rpx;
						margin-left: 4rpx;
					}

					.time {
						margin-left: 4rpx;
					}
				}
			}
		}
	}
</style>